import moment from 'moment';

const state = {
    // 统计类型
    faultList: getFaultList(),
    // 告警平均日趋势
    alarmDayList: getAlarmDayList(),
    //告警月趋势
    alarmMonthList: getAlarmMonthList()
};

const getters = {
    faultList: state => state.faultList,
    alarmDayList: state => state.alarmDayList,
    alarmMonthList: state => state.alarmMonthList
};

const mutations = {};

const actions = {};

export default {
    state,
    getters,
    actions,
    mutations
};
//告警与故障统计模拟数据
function getFaultList() {
    return [
        {
            name: '烟感',
            color: 'red',
            value: 27,
            faultValue: 10 // 故障次数
        },
        {
            name: '用水',
            color: '#FF9A23',
            value: 33,
            faultValue: 9
        },
        {
            name: '用电',
            color: '#00A0E9',
            value: 24,
            faultValue: 66
        },
        {
            name: '监控',
            color: '#0062B3',
            value: 16,
            faultValue: 15
        }
    ];
}

/** 告警日趋势模拟数据
 * {
            timeValue: dateList[i],
            alarmCount: alarmList[i],
            detailCount: detailList[i]
    }
 */
function getAlarmDayList() {
    let strDate = moment().format('MM-DD');
    let dateList = [
        strDate,
        '2:00',
        '4:00',
        '6:00',
        '8:00',
        '10:00',
        '12:00',
        '14:00',
        '16:00',
        '18:00',
        '20:00',
        '22:00'
    ];
    let alarmList = [
        '120',
        '140',
        '108',
        '141',
        '106',
        '128',
        '130',
        '80',
        '110',
        '100',
        '118',
        '132'
    ];
    let detailList = [
        '12',
        '14',
        '8',
        '8',
        '6',
        '8',
        '10',
        '5',
        '5',
        '30',
        '18',
        '12'
    ];
    let arr = [];
    for (let i = 0; i < dateList.length; i++) {
        const item = {
            timeValue: dateList[i],
            alarmCount: alarmList[i],
            detailCount: detailList[i]
        };
        arr.push(item);
    }
    return arr;
}

// 告警月趋势模拟数据
function getAlarmMonthList() {
    let dateList = [
        '1月',
        '2月',
        '3月',
        '4月',
        '5月',
        '6月',
        '7月',
        '8月',
        '9月',
        '10月',
        '11月',
        '12月'
    ];
    let alarmList = [50, 182, 174, 103, 93, 146, 174, 120, 102, 218, 135, 120];
    let detailList = [42, 173, 150, 82, 85, 139, 154, 102, 76, 204, 110, 100];
    let arr = [];
    for (let i = 0; i < dateList.length; i++) {
        const item = {
            timeValue: dateList[i],
            alarmCount: alarmList[i],
            detailCount: detailList[i]
        };
        arr.push(item);
    }
    return arr;
}